<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<jsp:include page="../../common/assets_header.jsp"/>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<html>
<head>

<script type="text/javascript">

jQuery(document).ready(function() {    
	
	  var enterpriseId = "${baseParameter.enterpriseId}";
	  if(enterpriseId != null && enterpriseId !="" ){
	 	 $("#enterpriseId").val(enterpriseId);
	 	var userId = "${baseParameter.userId}";
	 	getCompanyLinkman(enterpriseId);
	 	$("#userId").val(userId);
	 	/*getCompanyLinkman(enterpriseId); */
	 	/*  var userId = "${baseParameter.userId}";
	 	 alert(userId);
	 	$("#userId").val(userId); */
	  }
	  var paramScope = "${baseParameter.paramScope}";
	  
	  if(paramScope != null && paramScope !=""){
		  $("#paramScope").val(paramScope);
	  }
	  var paramLevel ="${baseParameter.paramLevel}";
	  if(paramLevel != null && paramLevel !=""){
		  $("#paramLevel").val(paramLevel);
	  }
	  var dataType="${baseParameter.dataType}";
	  if(dataType != null && dataType !=""){
		  $("#dataType").val(dataType);
	  }
});


function getCompanyLinkman(code){
	if(code !=""){
	$("#userId").empty();
	jQuery("<option value=''>请选择</option>").appendTo("#userId")
	 $.ajax({
		type : "GET",
		url : "<%=request.getContextPath()%>/base/parameter/linkman?companyCode="+code,
		dataType : 'json',
		async : false,
		success : function(data) {
				var option = "";
					data.forEach(function(linkman){
					   jQuery("<option value='"+linkman.baseCompanyLinkmanId+"'>"+linkman.firstName+linkman.lastName+"</option>").appendTo("#userId")
					});
				} 
	}) 
	 }
}

function check() {
	document.getElementById('ok').disabled = 'disabled';
}

function backparameterlist(){
	$("#baseParameterform").attr("action","<%=request.getContextPath()%>/base/parameter/list");
	$("#baseParameterform").submit();
}
</script>
</head>
<body >
	<!-- content -->	
		<div class="page-content">
			<div class="page-header">
				<h1>
					<c:if test="${baseParameter.baseParameterId==null }">新增参数</c:if>
						<c:if test="${baseParameter.baseParameterId!=null }">编辑参数</c:if>
								<small>
									<i class="icon-double-angle-right"></i>
									
								</small>
							</h1>
							
					
			</div>
				<div class="row">
					<c:if test="${success}">
						<div class="alert alert-block alert-success">
									<button class="close" data-dismiss="alert"><i class="icon-remove"></i></button>
									<strong><spring:message code="success"></spring:message>!</strong> <spring:message code="save success"></spring:message>！
						</div>
					</c:if>
					
					<c:if test="${success==false}">
						<div class="alert alert-danger">
							<button type="button" class="close" data-dismiss="alert"><i class="icon-remove"></i></button>
							<strong>
								<i class="icon-remove"></i>
								<strong><spring:message code="failure"></spring:message>!</strong> ${message}
							</strong>
						</div>
					</c:if>
					<div class="col-xs-12">
						<form action="<c:if test="${baseParameter.baseParameterId==null}">insert</c:if>
				  		  <c:if test="${baseParameter.baseParameterId!=null}">edit</c:if>" method="post" class="form-horizontal" id="baseParameterform"
						onsubmit="return check();">
						<input type="hidden" name="searchValue" value="${searchValue}" />
						<input type="hidden" name="id" value="${baseParameter.baseParameterId}"></input> 
						<input type="hidden" name="token" value="${token}"></input>

						<div class="form-group">
							<label class="col-sm-3 control-label no-padding-right" for="form-field-1">moduleName：</label>
							<div class="controls">

								<input type="text" maxLength="30"name="moduleName" value="${baseParameter.moduleName }"
									class="m-wrap" required />
							
								<span class="help-inline"></span>

							</div>

						</div>

						<div class="form-group">
							<label class="col-sm-3 control-label no-padding-right" for="form-field-1">paramKey：</label>
							<div class="controls">

								<input type="text" maxlength="200" name="paramKey"
									value="${baseParameter.paramKey}" class="m-wrap" required />
								<span class="help-inline"></span>

							</div>

						</div>

						<div class="form-group">
							<label class="col-sm-3 control-label no-padding-right" for="form-field-1">enterpriseId：</label>
							<div class="controls">

								<select class="m-wrap" name="enterpriseId" id="enterpriseId" onchange="getCompanyLinkman(this.value)" required>
										<option value="">请选择</option>
										<c:forEach items="${baseCompanyInfoList }" var="item">
											<option value="${item.companyCode}">${item.companyName}</option>
										</c:forEach>
									</select>
								<span class="help-inline"></span>

							</div>

						</div>

						<div class="form-group">
							<label class="col-sm-3 control-label no-padding-right" for="form-field-1">userId：</label>
							<div class="controls">

								<%-- <input type="text" maxlength="200" name="userId"
									value="${baseParameter.userId}" class="m-wrap" required /> --%>
								
								
								<select class="m-wrap" name="userId" id="userId"  required>
										<option value="">请选择</option>
										
									</select>
								<span class="help-inline"></span>

							</div>

						</div>

						<div class="form-group">
							<label class="col-sm-3 control-label no-padding-right" for="form-field-1">paramDesc：</label>
							<div class="controls">

								<input type="text" maxlength="200" name="paramDesc"
									value="${baseParameter.paramDesc}" class="m-wrap" required />
								<span class="help-inline"></span>

							</div>

						</div>

						
						
						<div class="form-group">
							<label class="col-sm-3 control-label no-padding-right" for="form-field-1">paramScope：</label>
							<div class="controls">
									<select class="m-wrap" name="paramScope" id="paramScope" required >
										<option value="">请选择</option>
										<option value="Global">Global</option>
										<option value="Portal">Portal</option>
										<option value="Module">Module</option>
									</select>
									<span class="help-inline"></span>

							</div>

						</div>

						
						<div class="form-group">
							<label class="col-sm-3 control-label no-padding-right" for="form-field-1">paramLevel：</label>
							<div class="controls">
									<select class="m-wrap" name="paramLevel" id="paramLevel" required>
										<option value="">请选择</option>
										<option value="Global">Global</option>
										<option value="Portal">Enterprise</option>
										<option value="Module">User</option>
									</select>
									<span class="help-inline"></span>

							</div>

						</div>
						
						<div class="form-group">
							<label class="col-sm-3 control-label no-padding-right" for="form-field-1">dataType：</label>
							<div class="controls">
									<select class="m-wrap" name="dataType" id="dataType" required>
										<option value="">请选择</option>
										<option value="String">String</option>
										<option value="Integer">Integer</option>
										<option value="Float">Float</option>
										<option value="Date">Date</option>
										<option value="DateTime">DateTime</option>
										<option value="Time">Time</option>
										<option value="JSON">JSON</option>
										<option value="Time">LOV</option>
									</select>
									<span class="help-inline"></span>

							</div>

						</div>
						
						<div class="form-group">
							<label class="col-sm-3 control-label no-padding-right" for="form-field-1">paramValue：</label>
							<div class="controls">

								<input type="text" maxlength="200" name="paramValue"
									value="${baseParameter.paramValue}" class="m-wrap" required />
								<span class="help-inline"></span>

							</div>

						</div>
						
						
						
						
						
						<div class="form-group">
							<label class="col-sm-3 control-label no-padding-right" for="form-field-1">valid：</label>
							<div class="col-sm-9">
								 <input type="radio"
									<c:if test="${baseParameter.valid==0 || baseParameter.baseParameterId==null}">checked="checked"</c:if>
									name="valid" value="0" /> <spring:message code="yes"></spring:message>

							
								<input type="radio" name="valid"
									<c:if test="${baseParameter.valid==1 }">checked="checked"</c:if>
									value="1" /> <spring:message code="no"></spring:message>

								
							</div>

						</div>
						
						
						<div class="form-actions center">

							<button type="submit" id="ok" class="btn btn-xs btn-primary">
								<spring:message code="btn.common.save"></spring:message>
							</button>
							<button type="button" onclick="backparameterlist();" class="btn btn-xs btn-primary">
								<spring:message code="btn.common.back"></spring:message>
							</button>

						</div>

					</form>

				</div>
				</div>

			<!-- BEGIN PAGE CONTAINER-->



		</div>
		<!-- content end -->
		

</body>
</html>